var Item = {
	Detail: {
		init: function() {
			Language.getCurrLanguage();
			Utils.loadJavascriptFile('/application/views/libraries/component/' + language + '.js');
			Utils.loadJavascriptFile('/application/views/libraries/utils/' + language + '.js');
			Utils.loadJavascriptFile('/application/views/module/Item/' + language + '.js');
			Utils.initAjax();
			
			Item.Detail.View.init();
		},
		
		View: {
			dataGridPanelContainer: '',
			
			init: function() {
				Item.Detail.View.dataGridPanelContainer = $('#dataGridPanel #dataGrid');
				Item.Detail.View.DataGrid.init();
			},
			
			DataGrid: {
				gameAreaCombogridLabelContainer: '',
				gameAreaCombogridInputContainer: '',
				accountValidateboxLabelContainer: '',
				accountValidateboxInputContainer: '',
				roleNameValidateboxLabelContainer: '',
				roleNameValidateboxInputContainer: '',
				itemComboboxLabelContainer: '',
				itemComboboxInputContainer: '',
				startDatetimeboxLabelContainer: '',
				startDatetimeboxInputContainer: '',
				endDatetimeboxLabelContainer: '',
				endDatetimeboxInputContainer: '',
				searchButtonContainer: '',
				
				init: function() {
					Item.Detail.View.DataGrid.gameAreaCombogridLabelContainer = $('#dataGridPanel #toolbar #gameAreaCombogridLabel');
					Item.Detail.View.DataGrid.gameAreaCombogridInputContainer = $('#dataGridPanel #toolbar #gameAreaCombogridInput');
					Item.Detail.View.DataGrid.accountValidateboxLabelContainer = $('#dataGridPanel #toolbar #accountValidateboxLabel');
					Item.Detail.View.DataGrid.accountValidateboxInputContainer = $('#dataGridPanel #toolbar #accountValidateboxInput');
					Item.Detail.View.DataGrid.roleNameValidateboxLabelContainer = $('#dataGridPanel #toolbar #roleNameValidateboxLabel');
					Item.Detail.View.DataGrid.roleNameValidateboxInputContainer = $('#dataGridPanel #toolbar #roleNameValidateboxInput');
					Item.Detail.View.DataGrid.itemComboboxLabelContainer = $('#dataGridPanel #toolbar #itemComboboxLabel');
					Item.Detail.View.DataGrid.itemComboboxInputContainer = $('#dataGridPanel #toolbar #itemComboboxInput');
					Item.Detail.View.DataGrid.startDatetimeboxLabelContainer = $('#dataGridPanel #toolbar #startDatetimeboxLabel');
					Item.Detail.View.DataGrid.startDatetimeboxInputContainer = $('#dataGridPanel #toolbar #startDatetimeboxInput');
					Item.Detail.View.DataGrid.endDatetimeboxLabelContainer = $('#dataGridPanel #toolbar #endDatetimeboxLabel');
					Item.Detail.View.DataGrid.endDatetimeboxInputContainer = $('#dataGridPanel #toolbar #endDatetimeboxInput');
					Item.Detail.View.DataGrid.searchButtonContainer = $('#dataGridPanel #toolbar #searchButton');
					Item.Detail.View.DataGrid.create();
				},
				
				create: function() {
					var width = $(document).width() - 40;
					var height = $(document).height() - 40;
					Item.Detail.View.dataGridPanelContainer.width(width);
					Item.Detail.View.dataGridPanelContainer.height(height);
					Item.Detail.View.dataGridPanelContainer.datagrid({
						fitColumns: false,
						toolbar: '#toolbar',
						columns: [[
							{
								field: 'functionName',
								title: itemDetailViewDataGridColumnTitle1,
								width: 100
							},
							{
								field: 'subFunctionName',
								title: itemDetailViewDataGridColumnTitle5,
								width: 100
							},
							{
								field: 'itemName',
								title: itemDetailViewDataGridColumnTitle2,
								width: 200,
							},
							{
								field: 'changeValue',
								title: itemDetailViewDataGridColumnTitle3,
								width: 80,
							},
							{
								field: 'operatorDateTime',
								title: itemDetailViewDataGridColumnTitle4,
								width: 150,
							},
						]],
						loadFilter: Utils.dataGridLoadFilter,
						pagination: true,
						pageSize: 50,
						pageList: [50, 100, 150, 200],
					});
					Component.Combogrid.GameArea.create(
						Item.Detail.View.DataGrid.gameAreaCombogridLabelContainer,
						Item.Detail.View.DataGrid.gameAreaCombogridInputContainer
					);
					Component.Validatebox.Account.create(
						Item.Detail.View.DataGrid.accountValidateboxLabelContainer,
						Item.Detail.View.DataGrid.accountValidateboxInputContainer
					);
					Component.Validatebox.RoleName.create(
						Item.Detail.View.DataGrid.roleNameValidateboxLabelContainer,
						Item.Detail.View.DataGrid.roleNameValidateboxInputContainer
					);
					Component.Combobox.Item.create(
						Item.Detail.View.DataGrid.itemComboboxLabelContainer,
						Item.Detail.View.DataGrid.itemComboboxInputContainer
					);
					Component.Datetimebox.Start.create(
						Item.Detail.View.DataGrid.startDatetimeboxLabelContainer,
						Item.Detail.View.DataGrid.startDatetimeboxInputContainer
					);
					Component.Datetimebox.End.create(
						Item.Detail.View.DataGrid.endDatetimeboxLabelContainer,
						Item.Detail.View.DataGrid.endDatetimeboxInputContainer
					);
					Item.Detail.View.DataGrid.searchButtonContainer.linkbutton({
						iconCls: 'icon-search',
						text: itemDetailViewDataGridToolbarButtonText1,
					});
					Item.Detail.View.DataGrid.searchButtonContainer.bind(
						'click',
						Item.Detail.View.DataGrid.doSearch
					);
				},
				
				doSearch: function() {
					Item.Detail.View.dataGridPanelContainer.datagrid({
						url: '/index.php/Item/detail/getListData',
						queryParams: {
							gameAreaId: Item.Detail.View.DataGrid.gameAreaCombogridInputContainer.combogrid('getValue'),
							account: Item.Detail.View.DataGrid.accountValidateboxInputContainer[0].value,
							roleName: Item.Detail.View.DataGrid.roleNameValidateboxInputContainer[0].value,
							startDateTime: Item.Detail.View.DataGrid.startDatetimeboxInputContainer.datetimebox('getValue'),
							endDateTime: Item.Detail.View.DataGrid.endDatetimeboxInputContainer.datetimebox('getValue'),
							id: Item.Detail.View.DataGrid.itemComboboxInputContainer.combobox('getValue'),
						}
					});
				},
			},
		},
	}
}